﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

namespace CSP.Web.UserControls
{
    public partial class MyHomeLeftNavigation : System.Web.UI.UserControl
    {
        private string _selectedStyle = "current";

        private MyHomeLeftNavigationLink _selectedNavigationLink = MyHomeLeftNavigationLink.NoAppoint;

        private int _uid;

        /// <summary>
        /// discuz路径
        /// </summary>
        private string _discuzUrl;

        /// <summary>
        /// 选中的样式
        /// </summary>
        public string SelectedStyle
        {
            get
            {
                return _selectedStyle;
            }
        }

        /// <summary>
        /// Uid
        /// </summary>
        protected int Uid
        {
            get
            {
                return _uid;
            }
        }

        /// <summary>
        /// 获取或设置选中的link
        /// </summary>
        public MyHomeLeftNavigationLink SelectedNavigationLink
        {
            get
            {
                return _selectedNavigationLink;
            }
            set
            {
                _selectedNavigationLink = value;
            }
        }

        /// <summary>
        /// 肖像图片URl
        /// </summary>
        protected string DiscuzUrl
        {
            get
            {
                return _discuzUrl;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            _discuzUrl = ConfigurationManager.AppSettings["DiscuzDomain.URL"].ToString();
            _uid = Convert.ToInt32(Session["Uid"]);
            Link_Photo.HRef = _discuzUrl+"/home.php?mod=space&uid="+Uid+"&do=album&view=me&from=space";
            Link_Space.HRef = _discuzUrl + "/?" + _uid;
            if (!IsPostBack)
            {
                AppointCurrentLink();
            }
        }

        /// <summary>
        /// 指定选中的链接
        /// </summary>
        private void AppointCurrentLink()
        {
            switch (_selectedNavigationLink)
            {
                //账户资料
                case MyHomeLeftNavigationLink.Accoun:
                    this.Link_Accoun.Attributes.Add("class", _selectedStyle);
                    break;
                case MyHomeLeftNavigationLink.ConsumeOrder:
                    this.Link_ConsumeOrder.Attributes.Add("class", _selectedStyle);
                    break;
                case MyHomeLeftNavigationLink.Credit:
                    this.Link_Credit.Attributes.Add("class", _selectedStyle);
                    break;
                case MyHomeLeftNavigationLink.Photo:
                    this.Link_Photo.Attributes.Add("class", _selectedStyle);
                    break;
                case MyHomeLeftNavigationLink.Space:
                    this.Link_Space.Attributes.Add("class", _selectedStyle);
                    break;
                case MyHomeLeftNavigationLink.Authentication:
                    this.Link_Authentication.Attributes.Add("class", _selectedStyle);
                    break;
                case MyHomeLeftNavigationLink.ServiceOrder:
                    this.Link_ServiceOrder.Attributes.Add("class", _selectedStyle);
                    break;
                case MyHomeLeftNavigationLink.ServiceInfo:
                    this.Link_ServiceInfo.Attributes.Add("class", _selectedStyle);
                    break;
                case MyHomeLeftNavigationLink.Shop:
                    this.Link_Shop.Attributes.Add("class", _selectedStyle);
                    break;
                case MyHomeLeftNavigationLink.ContactWay:
                    this.Link_ContactWay.Attributes.Add("class", _selectedStyle);
                    break;
                case MyHomeLeftNavigationLink.Address:
                    this.Link_Address.Attributes.Add("class", _selectedStyle);
                    break;
                default:
                    break;
            }
        }

    }

    /// <summary>
    /// MyHomeLeftNavigationLink
    /// </summary>
    public enum MyHomeLeftNavigationLink
    {

        /// <summary>
        /// 未指定
        /// </summary>
        NoAppoint = 0,

        /// <summary>
        /// 账户资料
        /// </summary>
        Accoun = 1,

        /// <summary>
        /// 我的合作订单
        /// </summary>
        ConsumeOrder = 2,

        /// <summary>
        /// 评价管理
        /// </summary>
        Credit = 3,

        /// <summary>
        /// 我的相册
        /// </summary>
        Photo = 4,

        /// <summary>
        /// 个人空间
        /// </summary>
        Space = 5,

        /// <summary>
        /// 资质认证
        /// </summary>
        Authentication = 6,

        /// <summary>
        /// 合作订单管理
        /// </summary>
        ServiceOrder = 7,

        /// <summary>
        /// 发布管理
        /// </summary>
        ServiceInfo = 8,

        /// <summary>
        /// 我的企业网站
        /// </summary>
        Shop = 9,

        /// <summary>
        /// 我的联系方式
        /// </summary>
        ContactWay = 10,

        /// <summary>
        /// 地理位置管理
        /// </summary>
        Address = 11

    }
}